package com.smart_environmental_protection.service.ServiceImp;

import com.smart_environmental_protection.dao.UserDao;
import com.smart_environmental_protection.pojo.User;
import com.smart_environmental_protection.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImp implements UserService {
@Resource
    private UserDao userDao;


    @Override
    public User login(User user) {
        return userDao.login(user);
    }

    @Override
    public User Userlogin(User user) {
        return userDao.Userlogin(user);
    }

    @Override
    public User getUserById(Integer id) {
        return userDao.getUserById(id);
    }

    @Override
    public int updateIcon(User user) {
        return userDao.updateIcon(user);
    }

    @Override
    public int InsertUser(User user) {
        User user1=userDao.Userlogin(user);
        if (user1!=null){
            return -1;
        }else {
            return userDao.InsertUser(user);
        }



    }

    @Override
    public int UpdateUser(User user) {
        return userDao.UpdateUser(user);
    }

    @Override
    public int UpdatePhone(User user) {
        User user1=userDao.Userlogin(user);
        if (user1!=null){
            return -1;
        }else {
            return userDao.UpdatePhone(user);
        }

    }

    @Override
    public int UpdatePws(User user) {
        return userDao.UpdatePws(user);
    }
}
